package com.onlinelearn.controllers;

import com.onlinelearn.content.model.po.CourseTeacher;
import com.onlinelearn.content.service.CourseTeacherService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 课程-教师关系表 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
@RequestMapping("courseTeacher")
public class CourseTeacherController {

    @Autowired
    private CourseTeacherService  courseTeacherService;


    @ApiOperation("根据课程id查询对应的师资列表")
    @GetMapping("/list/{courseId}")
    public List<CourseTeacher> getCourseTeacher(@PathVariable Long courseId){
        return courseTeacherService.getCourseTeacher(courseId);
    }

    @ApiOperation("添加师资信息")
    @PostMapping
    public CourseTeacher saveCourseTeacher(@RequestBody CourseTeacher courseTeacher){
        Long companyId = 1232141425L;
        return courseTeacherService.saveCourseTeacher(companyId,courseTeacher);
    }

    @ApiOperation("修改师资信息")
    @PutMapping
    public CourseTeacher editCourseTeacher(@RequestBody CourseTeacher courseTeacher){
        Long companyId = 1232141425L;
        return courseTeacherService.editCourseTeacher(companyId,courseTeacher);
    }

    @ApiOperation("删除师资信息")
    @DeleteMapping("/course/{courseId}/{id}")
    public void deleteCourseTeacher(@PathVariable Long courseId,@PathVariable Long id){
        Long companyId = 1232141425L;
        courseTeacherService.deleteCourseTeacher(companyId, courseId, id);
    }


}
